#include<func.h>
//只读
typedef struct student
{
    int stu_num;     //学号
    char name[256]; // 姓名
    int grade;       // 成绩
}Student;

// 读取结构体到文件中
int main(int argc,char*argv[])
{
    //./student file1 
    //读取到文件中
    ARGS_CHECK(argc,2);
    ERROR_CHECK(argv[1],-1,"open");
    FILE*fp =fopen(argv[1],"rb");
    
     
    Student st1 = {1,"wtto",98};
    Student st2 = {2,"xixi",78};
    Student st3 = {3,"koko",91};

    Student student[3] = {st1,st2,st3};

    printf("num = %d , name =%s  grade = %d",st1.stu_num,st1.name,st1.grade);
    fwrite(&st1,sizeof(st1),1,fp);

    printf("num = %d , name =%s  grade = %d",st2.stu_num,st2.name,st2.grade);
    fwrite(&st2,sizeof(st2),1,fp);

    printf("num = %d , name =%s  grade = %d",st3.stu_num,st3.name,st3.grade);
    fwrite(&st3,sizeof(st3),1,fp);
    fclose(fp);
    return 0;
}